#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QString>
#include "spreadsheet.h"
#include "findDialog.h"
#include <QLabel>
#include <QStringList>
#include <QAction>
#include <QMenu>
#include <QToolBar>

class MainWindow : public QMainWindow
{
    Q_OBJECT
public:
    explicit MainWindow(QWidget *parent = 0);
protected:
    void closeEvent(QCloseEvent *event);

private slots:
    void newFile();
    void open();
    bool save();
    bool saveAs();
    void find();
    void goToCell();
    void sort();
    void about();
    void openRecentFile();
    void updateStatusBar();
    void spreadsheetModified();
private:
    void createActions();
    void createMenus();
    void createContextMenu();
    void createToolBars();
    void createStatusBar();
    void readSettings();
    void writeSettings();
    bool okToContinue();
    bool loadFile(const QString& fileName);
    bool saveFile(const QString& fileName);
    void setCurrentFile(const QString& fileName);
    void updateRecentFileActions();
    QString strippedName(const QString& fullName);

    SpreadSheet *spreadsheet;
    FindDialog  *findDialog;
    QLabel *locationLabel;
    QLabel *formulaLabel;
    static QStringList recentFiles;
    QString curFile;

    enum{ MaxRecentFiles = 5};
    QAction *recentFileActions[MaxRecentFiles];
    QAction *separatorAction;

    QMenu *fileMenu;
    QMenu *editMenu;
    QMenu *toolsMenu;
    QMenu *optionsMenu;
    QMenu *helpMenu;

    QToolBar *fileToolBar;
    QToolBar *editToolBar;
    QAction* newAction;
    QAction* openAction;
    QAction* saveAction;
    QAction* saveAsAction;
    QAction* closeAction;
    QAction* exitAction;

    QAction* cutAction;
    QAction* copyAction;
    QAction* pasteAction;
    QAction* delAction;
    QMenu* selectSubMenu;
    QAction* selectRowAction;
    QAction* selectColumnAction;
    QAction* selectAllAction;
    QAction* findAction;
    QAction* goToCellAction;

    QAction* sortAction;
    QAction* recalculateAction;

    QAction* showGridAction;
    QAction* autoRecalculateAction;

    QAction* aboutAction;
    QAction* aboutQtAction;
};

#endif // MAINWINDOW_H
